package com.itxulin.config;


import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MpConfig {
    //配置mybatisplus分页查询拦截器

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //1.定义mp拦截器
        MybatisPlusInterceptor mpI=new MybatisPlusInterceptor();
        //2.添加具体的拦截器
        mpI.addInnerInterceptor(new PaginationInnerInterceptor());
        //3.开启乐观锁拦截器
        mpI.addInnerInterceptor(new OptimisticLockerInnerInterceptor());

        return mpI;
    }

}
